$(function(){
	//菜单状态,true表示打开,false表示关闭
	var menu = {};
	menu.open = function(){
		$('#left').css({'display':'block'});
		$('#content').css({'margin-left':'160px'});	
		menu.setState(true);
	};
	
	menu.close = function(){
		$('#left').css({'display':'none'});
		$('#content').css({'margin-left':'0px'});
		$('#content table').css({width:'100%'});
		menu.setState(false);
	};
	
	menu.toggle = function(){
		var state = menu.getState();		
		if(state){
			menu.close();
		}else{
			menu.open();
		}		
	};
	
	menu.ini = function(){
		var state = menu.getState();		
		if(state){
			menu.open();
		}else{
			menu.close();
		}	
	};
	
	menu.setState = function(state){
		var value = state ? '1':'0';
		var name = 'dw_msku_menu';		
		var Days = 30; //此 cookie 将被保存 30 天
		var exp  = new Date();
		exp.setTime(exp.getTime() + Days*24*60*60*1000);
		document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();		
	};
	
	menu.getState = function(){
		var name = 'dw_msku_menu';
		var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
		var state = true;
	    if(arr != null){
	    	var value = decodeURI(arr[2]);	    	
	    	state = decodeURI(arr[2])==1?true:false;
	    } 
	    return state;	
	};
	
	$("#menu_toggle").click(function () {
		menu.toggle();		
	});
	
	menu.ini();
	
});